package com.example.learn01.config;

import com.example.learn01.config.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


    @Configuration
    public class InterceptorConfig implements WebMvcConfigurer{
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(jwtInterceptor()) //自己建立的拦截器
                    .addPathPatterns("/**") //设置进行拦截所有请求
                    .excludePathPatterns("/user/login","/user/export","/**/import"); //设置不拦截的请求
            }
       // 拦截器注入到容器
        @Bean
        public JwtInterceptor jwtInterceptor() {
            return new JwtInterceptor();
        }

    }
